package com.exercises;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class Exercise171 {

    public static void main(String[] args) {
//        System.out.println(new Exercise171().titleToNumber("AB"));
        System.out.println(Integer.toBinaryString(4));
        System.out.println(Integer.toBinaryString(~4));
    }

    public int titleToNumber(String columnTitle) {
        int n = columnTitle.length();
        int result = 0;
        int power = 1;
        for (int i = n - 1; i >= 0; i--) {
            int current = columnTitle.charAt(i) - 'A' + 1;
            result += current * power;
            power *= 26;
        }
        return result;
    }

}
